import 'package:flutter/material.dart';

class Clock extends StatelessWidget {
  const Clock({super.key});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        print('点击了牵挂闹钟');
      },
      child: Container(
        // alignment: Alignment.center,
        margin: const EdgeInsets.fromLTRB(10, 10, 10, 0),
        decoration: const BoxDecoration(
          //圆角半径
          borderRadius: BorderRadius.all(Radius.circular(12.0)),
          //背景色
          color: Color(0xFFE3EFF3),
        ),
        child: Container(
          padding: const EdgeInsets.fromLTRB(10, 12, 0, 12),
          child: Row(
            children: [
              Stack(
                children: [
                  Container(
                    margin: const EdgeInsets.all(6),
                    child:
                        Image.asset("images/homePage/smart_clock_icon.png", width: 20, height: 20),
                  ),
                  Positioned(
                    top: 0,
                    right: 0,
                    child: Visibility(
                        visible: true,
                        child: CustomPaint(
                          size: const Size(10, 10),
                          painter: MyPainter(),
                        )),
                  )
                ],
              ),
              Container(width: 10),
              Text("牵挂闹钟发来一条消息!")
            ],
          ),
        ),
      ),
    );
  }
}

class MyPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint()
      ..color = Colors.red
      ..style = PaintingStyle.fill;

    final center = Offset(size.width / 2, size.height / 2);
    final radius = size.width / 2;

    canvas.drawCircle(center, radius, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}
